#include "../Header/String.h"

String::String()
{

}

String::~String()
{

}

char** String::NewStringArray(_utInt32 size, ...)
{
	char** output = new char*[size];
	char* value;
	va_list marker;
	va_start(marker, size);
	for (register int i = 0; i < size; i++)
	{
		value = va_arg(marker, char*);
		_utInt32 strSize = strlen(value) + 1;
		output[i] = new char[strSize];
		strcpy(output[i], value);
	}
	va_end(marker);
	return output;
}

char** String::CpyStringArray(char** src, _utInt32 target, _utInt32 size)
{
	char** des = new char*[size];
	for (register int i = target; i < target + size; i++)
	{
		_utInt32 strSize = strlen(src[i]) + 1;
		des[i] = new char[strSize];
		strcpy(des[i], src[i]);
	}
	return des;
}

void String::AddString(char* des, char* strFront, char* strBehind)
{
	_utInt32 sizeF = strlen(strFront);
	_utInt32 sizeB = strlen(strBehind);
	des = new char[sizeF + sizeB + 1];
	strcpy(des, strFront);
	strcpy(des + sizeF, strBehind);
}